import { Loading } from "element-ui";
import "./loading_reset.css";

const loadOption = {
  fullscreen: true,
  lock: true,
  text: "加载中...",
  spinner: "el-icon-loading",
  background: "rgba(255,255,255,0.8 )",
};

let loadingInstance;

export default class loadEvents {
  constructor(vueThis) {
    this.vm = vueThis; //vue中的this  也可以不用
    this.loadingInstance = Loading.service(loadOption);
    this.loadingMask = document.querySelector('.el-loading-mask')
  }
  open() {
    // this.loadingInstance = Loading.service(loadOption);

    if (this.loadingMask) {
      this.loadingMask.style.cssText += " cursor: pointer !important;";
      this.loadingMask.addEventListener("contextmenu", (e) => {
        e.preventDefault();
      });
    }
    setTimeout(() => {
      // const loadingMask = document.querySelector(".el-loading-mask");
      this.loadingMask.style.cssText += " cursor: pointer !important;";
      this.loadingMask.addEventListener("contextmenu", (e) => {
        e.preventDefault();
      });
    });
  }
  close() {
    this.loadingInstance.close();
  }
}
